#include<bits/stdc++.h>
using namespace std;
struct E{
	int u,v,w;
}a[2001];
struct G{
	int nxt,to,dis;
}e[4001];
int n,ans,ne,idx;
int dfn[2001],sz[2001],dis[2001][2001],sum[2001][2001],h[2001];
inline int read()
{
	int x(0);char ch(getchar());
	while(ch<48||ch>57) ch=getchar();
	while(ch>=48&&ch<=57) x=x*10+(ch^48),ch=getchar();
	return x;
}
void add(int x,int y,int z)
{
	e[++ne].nxt=h[x];
	e[ne].to=y,e[ne].dis=z,h[x]=ne;
}
void go(int x,int f)
{
	dfn[x]=++idx,sz[x]=1;
	for(int i=h[x];i;i=e[i].nxt)
	{
		int to=e[i].to;
		if(to!=f) 
		{
			go(to,x);
			sz[x]+=sz[to];
		}
	}
}
void dfs(int x,int y,int f,int z)
{
	if(x!=z) dis[z][dfn[x]]=y;
	for(int i=h[x];i;i=e[i].nxt)
	{
		int to=e[i].to;
		if(to!=f) dfs(to,min(y,e[i].dis),x,z);
	}
}
int main()
{
	freopen("tatooine.in","r",stdin);
	freopen("tatooine.out","w",stdout);
	n=read();
	for(int i=1;i<n;i++) 
	{
		a[i].u=read(),a[i].v=read(),a[i].w=read();
		add(a[i].u,a[i].v,a[i].w),add(a[i].v,a[i].u,a[i].w);
	}
	go(1,0);
	for(int i=1;i<n;i++) if(dfn[a[i].u]>dfn[a[i].v]) swap(a[i].u,a[i].v);
	for(int i=1;i<=n;i++) dfs(i,1000000001,0,i);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			sum[i][j]=sum[i][j-1]+dis[i][j];
	for(int i=1;i<n;i++)
	{
		ans=0;
		for(int j=1;j<=n;j++)
		{
			if(dfn[a[i].v]<=dfn[j]&&dfn[j]<=dfn[a[i].v]+sz[a[i].v]-1) ans+=sum[j][dfn[a[i].v]+sz[a[i].v]-1]-sum[j][dfn[a[i].v]-1];
			else ans+=sum[j][dfn[a[i].v]-1]+sum[j][n]-sum[j][dfn[a[i].v]+sz[a[i].v]-1];
		}
		ans>>=1;
		printf("%d\n",ans);
	}
	return 0;
}

